pub fn odd_fibnacci_sum(threshold: u32) -> u32 {
    if threshold < 1 {
        return 0;
    }

    fn fibonacci_generator(threshold: u32) -> impl Iterator<Item = u32> {
        let mut prev = 0;
        let mut curr = 1;
        std::iter::from_fn(move || {
            if curr >= threshold {
                None
            } else {
                let next = prev + curr;
                prev = curr;
                curr = next;
                Some(prev)
            }
        })
    }

    fibonacci_generator(threshold).filter(|&x| x % 2 == 1).sum()
}
